import { talkUd } from 'store/modules/types';
import router from 'router/index';
import Storage from 'util/lib/storage';
import {isEmptyObject} from 'util/lib/remex';
import io from 'socket.io-client';

const state = {
  c_talkDetail: {
    //存放用户
    socket: '',
    //存放历史记录
    messHistory: {
      infos: [],
      allMessage: []
    }
  }
}

//getters
const getters = {
  c_talkDetail : state => state.c_talkDetail
}

//actions
const actions = {
  [talkUd.A.GET_SOCKET]({commit, state}) {
    let ssUrl = 'http://www.qiufengh.com:9090/'
    if(process.env.NODE_ENV === 'development') {
      ssUrl = 'localhost:9090/'
    }
    commit(talkUd.SET_SOCKET ,io.connect(ssUrl))
  }
}

//mutaions
const mutations = {
  [talkUd.SET_SOCKET](state, data) {
    state.c_talkDetail.socket = data;
  }
}

export default {
  state,
  getters,
  actions,
  mutations
}



